package week5;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Scanner;
/**
 * Created by dell on 2017/3/26.
 */
public class TryCatchFinallyFileUtil2 {
    public static String readFile(String name) throws FileNotFoundException {
        StringBuilder text = new StringBuilder();
        try(Scanner console = new Scanner(new FileInputStream(name))) {
            while(console.hasNext()) {
                text.append(console.nextLine())
                        .append('\n');
            }
        } return text.toString();
    }
}
